<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Cases extends MY_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */

	public function __construct() {
		parent::__construct();
		 $this->load->model('Category_model', 'c');
		 $this->load->model('Article_model', 'article');
//		 $this->load->model('Comment_model', 'comment');
		 $this->load->model('Tag_model','tag');
		 $this->load->model('Tagrelation_model','tr');
		 $this->load->model('Advertisement_model', 'ad');
	}

	public function index(){
		$this->load->model('Article_model', 'article');
		$this->_d['alias'] = 'cases';
		$casecate = $this->c->O(array('alias'=>'case'),'cateid');
		$this->_d['list'] = $this->article->L(array('cateid'=>$casecate['cateid'],'status'=>'1'),'articleid,title,sourceimage',0,0,'sort');
		$this->load->view($this->_d['cfg']['tpl'] . 'case_list', $this->_d);
	}

	public function detail($articleid=''){
		if ($articleid == '') $articleid = $this->_d['case'][0]['articleid'];
		$row = $this->article->O(array('articleid'=>$articleid));
		if (empty($row)) show_404();
		$row['attachment'] = $this->getAttach($articleid,'article');
		$this->_d['row'] = $row;
		$this->_d['articleid'] = $articleid;
		$this->load->view($this->_d['cfg']['tpl'] . 'case', $this->_d);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */